namespace FastNetCore.Core.Options;


public enum SQLExecStatus
{
    None,
    Success,
    Failure
}

public class DBExecResult
{
    public int UpdateNum { get; set; }
    
    public int InsertNum { get; set; }
    
    public SQLExecStatus Status { get; set; }
    
    public string ErrorMessage { get; set; }
    
    public string ErrorTrace { get; set; }
    
    public DBExecResult()
    {
        this.UpdateNum = 0;
        this.InsertNum = 0;
        this.Status = SQLExecStatus.None;
        this.ErrorMessage = string.Empty;
        this.ErrorTrace = string.Empty;
    }

    public DBExecResult(DBExecResult result)
        : this()
    {
        this.Assign(result);
    }

    public DBExecResult(SQLExecStatus status)
        : this()
    {
        this.Status = status;
    }

    public DBExecResult(SQLExecStatus status, string error)
        : this()
    {
        this.Status = status;
        this.ErrorMessage = error;
    }

    public DBExecResult(SQLExecStatus status, string error, string trace)
        : this()
    {
        this.Status = status;
        this.ErrorMessage = error;
        this.ErrorTrace = trace;
    }

    public void Assign(DBExecResult result)
    {
        this.UpdateNum = result.UpdateNum;
        this.InsertNum = result.InsertNum;
        this.Status = result.Status;
        this.ErrorMessage = result.ErrorMessage;
        this.ErrorTrace = result.ErrorTrace;
    }
}

public class DBExecResult<T> : DBExecResult
{
    public T Result { get; set; }
    
    public DBExecResult()
    {
        this.Result=default(T);
    }

    public DBExecResult(DBExecResult result)
        : base(result)
    {
        this.Result=default(T);
    }

    public DBExecResult(SQLExecStatus status)
        : base(status)
    {
        this.Result=default(T);
    }
    
    public DBExecResult(T data,SQLExecStatus status)
        : base(status)
    {
        this.Result=data;
    }

    public DBExecResult(SQLExecStatus status, string error)
        : base(status,error)
    {
        this.Result=default(T);
    }
    
    public DBExecResult(T data,SQLExecStatus status, string error)
        : base(status,error)
    {
        this.Result=data;
    }

    public DBExecResult(SQLExecStatus status, string error, string trace)
        : base(status,error,trace)
    {
        this.Result=default(T);
    }
}